Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement authority module #1815

Merged
merged 35 commits into from
Mar 5, 2024
Merged

feat: implement authority module #1815

merged 35 commits into from
Mar 5, 2024

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Feb 27, 2024

Description

  • Add authority module containing object Policies matching address with policy types
  • Refactor messages to use this module for authorization check
  • Refactor message tests to use mocks for IsAuthorized for better unit testing
  • Migration script observer.Params -> authority.Policies
  • Add UpdatePolicies message to update the policies.

Closes: #1714

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 33.36%. Comparing base (5297c87) to head (da33217).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1815      +/-   ##
===========================================
- Coverage    39.92%   33.36%   -6.57%     
===========================================
  Files          206      130      -76     
  Lines        12617     9205    -3412     
===========================================
- Hits          5037     3071    -1966     
+ Misses        7183     5909    -1274     
+ Partials       397      225     -172     
Files Coverage Δ
x/authority/genesis.go 100.00% <100.00%> (ø)
x/authority/keeper/grpc_query_policies.go 100.00% <100.00%> (ø)
x/authority/keeper/msg_server_update_policies.go 100.00% <100.00%> (ø)
x/authority/keeper/policies.go 100.00% <100.00%> (ø)
...le/keeper/msg_server_deploy_fungible_coin_zrc20.go 94.11% <100.00%> (ø)
...ngible/keeper/msg_server_deploy_system_contract.go 67.44% <100.00%> (ø)
.../fungible/keeper/msg_server_remove_foreign_coin.go 100.00% <100.00%> (ø)
...le/keeper/msg_server_udpate_zrc20_liquidity_cap.go 100.00% <100.00%> (ø)
...ible/keeper/msg_server_update_contract_bytecode.go 92.50% <100.00%> (ø)
...ngible/keeper/msg_server_update_system_contract.go 79.59% <100.00%> (ø)
... and 5 more

... and 81 files with indirect coverage changes

Copy link

!!!WARNING!!!
nosec detected in the following files: x/observer/keeper/msg_server_update_observer_test.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Feb 29, 2024
@lumtis lumtis marked this pull request as ready for review March 1, 2024 10:07
Copy link
Contributor

@skosito skosito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, couple smaller comments

contrib/localnet/scripts/start-zetacored.sh Outdated Show resolved Hide resolved
docs/spec/crosschain/messages.md Show resolved Hide resolved
proto/authority/policies.proto Outdated Show resolved Hide resolved
testutil/keeper/observer.go Show resolved Hide resolved
x/observer/types/message_crosschain_flags.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ws4charlie ws4charlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few minor comments

@ws4charlie ws4charlie self-requested a review March 1, 2024 19:11
@skosito skosito self-requested a review March 5, 2024 13:40
@lumtis
Copy link
Member Author

lumtis commented Mar 5, 2024

Seems like there is bug with Codecov, the diff coverage is -6% while the new addition is almost fully covered, will merge and check if there is a bug, otherwise gonna see what's wrong

@lumtis lumtis merged commit 422e00e into develop Mar 5, 2024
20 of 21 checks passed
@lumtis lumtis deleted the feat/authority branch March 5, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce an authority module
4 participants